package org.luxor.system.transform;

import org.luxor.commons.security.entity.UserSubject;
import org.luxor.system.entity.SysUserEntity;

/**
 * 用户信息转换器
 *
 * @author Mr.Yan  @date: 2020/9/9
 */
public class UserTransform {

    public static UserSubject toUserSubject(SysUserEntity sysUser) {
        UserSubject userSubject = new UserSubject();
        userSubject.setTenantId(sysUser.getTenantId());
        userSubject.setDeptId(sysUser.getDeptId());
        userSubject.setUserId(sysUser.getId());
        userSubject.setUsername(sysUser.getUserName());
        userSubject.setPassword(sysUser.getPassword());
        userSubject.setEnabled(sysUser.getEnabled());
        userSubject.setAccountNonLocked(!sysUser.getAccountLocked());
        userSubject.setAccountNonExpired(true);
        userSubject.setCredentialsNonExpired(true);
        return userSubject;
    }
}
